home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / c_scripts / webspf.perl < prev    next >
Encoding:
Text File  |  1999-04-11  |  3.1 KB  |  85 lines

  1. #!/usr/bin/perl
  2. #
  3. # Web Spoof
  4. # Pavel Aubuchon-Mendoza [admin@deviance.org][http://www.deviance.org]
  5. #
  6. # Summary: 
  7. # Works as a normal command line web retrieval script,
  8. # except will spoof the referer. This can be left to the script to do,
  9. # or specified in the command line. This will bypass any kind of reference
  10. # checking, in most cases. Will also screw up the REMOTE_HOST variable which
  11. # some cgi scripts use, but the correct IP will of course be sent. Default
  12. # broswer is Netscape 4.5 under Win95. This can be changed in the script.
  13. #
  14. # Usage:  - default output is standard out, to save to a file
  15. #           you will need to redirect it, especially for  
  16. #           binary/image files -
  17. #
  18. #  ./webspf.pl [file] <referer>
  19. #
  20. # Examples:
  21. #
  22. #  ./webspf.pl language.perl.com/info/software.html > software.html
  23. #      - referer would be language.perl.com/info/index.html -
  24. #
  25. #  ./webspf.pl www.linux.org/images/logo/linuxorg.gif > penguin.gif
  26. #      - referer would be www.linux.org/images/logo/index.html -
  27. #
  28. #  ./webspf.pl www.linux.org/ www.freebsd.org/whatever.html > index.html
  29. #      - referer would be www.freebsd.org/whatever.html -
  30. #
  31. #
  32.  
  33.  
  34. use IO::Socket;
  35.  
  36. $loc = $ARGV[0];                             # www.a.com/test.html
  37. $temp = reverse($loc);                       # lmth.tset/moc.a.www
  38. $host = substr($temp,rindex($temp,"\/")+1);  # moc.a.www
  39. $host = reverse($host);                      # www.a.com
  40. $dir = substr($loc,index($loc,"\/"));        # /test.html
  41.  
  42. $referer = $ARGV[1];                         # <blank>
  43. if($referer eq "") {                         # true
  44.  $temp = substr($temp,index($temp,"\/")+1);  # /moc.a.www
  45.  $temp = reverse($temp);                     # www.a.com/
  46.  $referer = $temp . "index\.html";           # www.a.com/index.html
  47.  }                                           # spoofed referer!
  48.  
  49. print STDERR "\nWebSpoof v1.0 : 12/18/1998\n";
  50. print STDERR "Pavel Aubuchon-Mendoza + http://www.deviance.org\n\n";
  51.  
  52. $res = 0;
  53. $handle = IO::Socket::INET->new(Proto => "tcp",
  54.    PeerAddr => $host,
  55.    PeerPort => 80) or $res = 1;
  56. if($res eq 0) {
  57.  $handle->autoflush(1);
  58.  print STDERR "\[Connected to $host\]\n";
  59.  print $handle "GET $dir HTTP/1.0\n";
  60.  print $handle "Referer: $referer\n";
  61.  print $handle "Connection: Close\n";
  62.  print $handle "User-Agent: Mozilla\/4.5 [en] \(Win95\; I\)\n";
  63.  print $handle "Host: $host\n";  
  64.  print $handle "Accept: image\/gif\, image\/x-xbitmap\, image\/jpeg\, image\/pjpeg\, image\/png\, *\/*\n";
  65.  print $handle "Accept-Encoding: gzip\n";
  66.  print $handle "Accept-Language: en\n";
  67.  print $handle "Accept-Charset: iso-8859-1\,\*\,utf-8\n\n";
  68.  while($temp ne "") { # read some headers
  69.   $temp = <$handle>;
  70.   chop($temp);chop($temp);
  71.   @sort = split(/:/,$temp);
  72.   if(@sort[0] =~ /server/i)  { print STDERR " \[$temp\]\n"; }
  73.   if(@sort[0] =~ /date/i)    { print STDERR " \[$temp\]\n"; }
  74.   if(@sort[0] =~ /content/i) { print STDERR " \[$temp\]\n"; }
  75.   }
  76.  print STDERR "\[Recieving data\]\n"; 
  77.  binmode(STDOUT);
  78.  while(<$handle>) {
  79.   print "$_";
  80.   }
  81.  close($handle);
  82.  print STDERR "\[Connection Closed\]\n";
  83.  } else { print STDERR "\[Could not connect to $host\]\n"; }
  84.